package cn.wyl.feignclient;

import cn.wyl.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            //降级方法
            @Override
            public User getById(Long id) {
                throwable.printStackTrace();
                return new User(-1l,"熔断了","被降级工厂熔断了");
            }
        };
    }
}
